package zhh.tangbao.wechat.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import zhh.tangbao.auxiliary.entity.SystemOpinion;
import zhh.tangbao.auxiliary.vo.opinion.OpinionInfoVo;
import zhh.tangbao.commodity.entity.CommodityMachineHistory;
import zhh.tangbao.commodity.entity.CommodityOrder;
import zhh.tangbao.commodity.pojo.CommodityOrderReceipt;
import zhh.tangbao.syslog.entity.WorkRecord;
import zhh.tangbao.system.entity.PagerEntity;
import zhh.tangbao.wechat.dto.WeChatMachineQueryDto;
import zhh.tangbao.wechat.dto.WeChatOrderQueryDto;
import zhh.tangbao.wechat.dto.WeChatUserLoginDto;
import zhh.tangbao.wechat.dto.WeChatUserQueryDto;
import zhh.tangbao.wechat.dto.commodity.CommodityQueryDto;
import zhh.tangbao.wechat.dto.opinion.UserOpinionQueryDto;
import zhh.tangbao.wechat.dto.replenishment.ReplenishmentMachineStockQueryDto;
import zhh.tangbao.wechat.dto.replenishment.ReplenishmentStockDataDto;
import zhh.tangbao.wechat.dto.worker.WorkerRecordQueryDto;
import zhh.tangbao.wechat.entity.WeChatUser;
import zhh.tangbao.wechat.pojo.CartItem;
import zhh.tangbao.wechat.vo.*;
import zhh.tangbao.wechat.vo.cart.CartItemVo;
import zhh.tangbao.wechat.vo.commodity.CommodityPageInMachineVo;
import zhh.tangbao.wechat.vo.opinion.UserOpinionListItemVo;
import zhh.tangbao.wechat.vo.order.OrderDetailVo;
import zhh.tangbao.wechat.vo.replenishment.ReplenishmentMachineStockVo;
import zhh.tangbao.wechat.vo.worker.WorkerPanel;

import java.util.List;
import java.util.Map;

/**
 * 2023/2/27
 * @author 粥灰灰
 * @version 1.0
 * 微信服务
 */
public interface WeChatService {

    WeChatLoginVo login(WeChatUserLoginDto dto);

    void logout();

    WeChatUser getWeChatUserByToken(String token);

    /**
     * 过期返回True
     * 没过期则更新最后登录时间并返回False
     * @param weChatUser
     * @return
     */
    boolean updateIfNotExpire(WeChatUser weChatUser);

    List<WeChatCommodityMachineVo> machinePage(WeChatMachineQueryDto dto);

    Integer machineCount(WeChatMachineQueryDto dto);

    /**
     * 用户查阅自己的订单记录
     */
    List<WeChatCommodityOrderVo> wechatPage(WeChatOrderQueryDto dto);

    int wechatOrderCount(WeChatOrderQueryDto dto);

    /**
     * 由用户端调用的删除订单操作
     * @param id 订单编号
     * @return
     */
    int wechatDeleteOrder(String id);

    /**
     * 采用老式分页的查询方式，搜索用户查看的售货机历史记录
     */
    List<WeChatCommodityMachineHistoryVo> userMachineHistoryPage(WeChatMachineQueryDto dto);

    Integer userMachineHistoryCount(WeChatMachineQueryDto dto);

    /**
     * 更新或添加用户的新售货机浏览记录
     * 如果用户是从历史记录中进入则会带有历史记录的ID
     * 这时候就更新历史记录的最新浏览时间readTime
     */
    Integer upsertMachineHistory(CommodityMachineHistory history);

    /**
     * 用户购买商品操作
     * @return
     */
    Map<String, String> buy(CommodityOrder order);

    /**
     * 标记用户的订单付款时间，并将订单加入取货队列种
     */
    int orderPayment(String orderId);

    /**
     * 标记订单的支付时间并加入待取货队列
     */
    CommodityOrderReceipt getReceipt(String orderId);

    int waitCount(String machineId, String orderId);

    int cancelOrder(String orderId);

    List<WeChatUserListOptionsVo> userListOptions(String queryString);

    Page<WeChatUser> page(WeChatUserQueryDto dto);

    int batchDeleteReplenishment(List<String> ids);

    WeChatUser getWeChatUserById(String id);

    PagerEntity<CommodityPageInMachineVo> commodityPageInMachine(PagerEntity<CommodityPageInMachineVo> pager, CommodityQueryDto dto);

    String getPhoneNumber(String getPhoneCode);

    /**
     * 获取当前登录人员的购物车数据
     */
    List<CartItemVo> userCart();

    void addUserCart(CartItem item);

    int deleteUserCart(Integer stockIndex, Integer stockId);

    Map<String, String> requestPayment(String orderId);

    OrderDetailVo getWeChatOrderDetail(String id);

    WorkerPanel getWorkerPanel();

    Page<WorkRecord> getWorkerRecordList(WorkerRecordQueryDto dto);

    int submitRecord(WorkRecord record);

    PagerEntity<ReplenishmentMachineStockVo> machineStockPager(PagerEntity<ReplenishmentMachineStockVo> pager, ReplenishmentMachineStockQueryDto dto);

    int replenishmentMachineStockData(ReplenishmentStockDataDto dto);

    Page<UserOpinionListItemVo> getUserOpinionPage(UserOpinionQueryDto dto);

    OpinionInfoVo getUserOpinionDetail(String id);

    int submitOpinion(SystemOpinion opinion);
}
